﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="ServiceList.aspx.cs" Inherits="AB.ServiceDirectory.Design.Services.ServiceList" %>
<%@ Import Namespace="AB.ServiceDirectory" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <%--<link href="../style/jquery.ui/calendar/css/datepicker.css" rel="stylesheet" type="text/css" />
    <script src="../js/calendar/datepicker.js" type="text/javascript"></script>
    <script src="../js/calendar/eye.js" type="text/javascript"></script>
    <script src="../js/calendar/layout.js" type="text/javascript"></script>--%>
    <script type="text/javascript">
        function confirm_active() {
            return confirm('Do you want to make this Service active?');
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentTitle" runat="server">
    <h2>Service List</h2>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Content" runat="server">
    <div class="grid740 simplebox">
        <asp:UpdatePanel ID="UpdatePanelServiceList" runat="server">
            <Triggers>
                <%--<asp:AsyncPostBackTrigger runat="server" ControlID="ButtonCopy" EventName="click"/>--%>
                <asp:PostBackTrigger runat="server" ControlID="ButtonCopy"/>
            </Triggers>
            <ContentTemplate>
                <div class="titleh">
                    <h3 class="sorting_range">
                        <asp:LinkButton ID="LinkButtonAll" runat="server" CssClass="hg-blue" CommandName="all" OnCommand="FilterByLetters_Command">All</asp:LinkButton>
                        <asp:LinkButton ID="LinkButton09" runat="server" CommandName="09" OnCommand="FilterByLetters_Command">0-9</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonAE" runat="server" CommandName="ae" OnCommand="FilterByLetters_Command">A B C D E</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonFJ" runat="server" CommandName="fj" OnCommand="FilterByLetters_Command">F G H I J</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonKN" runat="server" CommandName="kn" OnCommand="FilterByLetters_Command">K L M N </asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonOR" runat="server" CommandName="or" OnCommand="FilterByLetters_Command">O P Q R</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonSV" runat="server" CommandName="sv" OnCommand="FilterByLetters_Command">S T U V</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonWZ" CssClass="last" runat="server" CommandName="wz"
                            OnCommand="FilterByLetters_Command">W X Y Z</asp:LinkButton>
                        <span class="right">
                            <asp:LinkButton ID="ButtonCopy" runat="server" CssClass="hg-blue" 
                            onclick="ButtonCopy_Click">Copy</asp:LinkButton>
                            <asp:LinkButton ID="ButtonCreate" runat="server" CssClass="hg-blue" 
                            PostBackUrl="~/Services/ServiceDetails.aspx">Create</asp:LinkButton>
                            <asp:CheckBox ID="CheckBoxInactive" runat="server" Text="Include In-active" AutoPostBack="True"
                                OnCheckedChanged="CheckBoxInactive_CheckedChanged" />
                        </span>
                    </h3>
                </div>
                <asp:GridView ID="GridViewServiceList" CssClass="tablesorter" runat="server" AutoGenerateColumns="False"
                    DataSourceID="ObjectDataSourceServiceList" AllowPaging="True" 
                    PageSize="15" AllowSorting="True">
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <input id="RadioButton" type="radio" name="RadioButton" value='<%#Eval("ServiceId")%>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <%--<asp:HyperLinkField DataNavigateUrlFields="ServiceId" DataNavigateUrlFormatString="~/Services/ServiceDetails.aspx?id={0}"
                            DataTextField="ServiceName" HeaderText="Service Name" SortExpression="Service Name" >
                            <HeaderStyle CssClass="header" />    
                        </asp:HyperLinkField>--%>
                        <asp:TemplateField HeaderText="Service Name" SortExpression="ServiceName">
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButtonServicename" runat="server" CommandName='<%# Eval("ServiceId") %>'
                                    CommandArgument='<%#Eval("IsActive") %>' OnCommand="LinkButtonServiceName_Command"
                                    Text='<%# Eval("ServiceName") %>'
                                    OnClientClick='<%# !(bool)Eval("IsActive") ? "return confirm_active();" : string.Empty %>'></asp:LinkButton>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Description" SortExpression="Description">
                            <ItemTemplate>
                                <%# StringTools.Substring(Eval("ShortDescription"), 0, 50, true)%>
                                </ItemTemplate>
                            <HeaderStyle CssClass="header" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Service Type" SortExpression="ServiceType">
                            <ItemTemplate>
                                <%# Eval("ServiceType") %>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Contact" SortExpression="ContactName">
                            <ItemTemplate>
                                <%# string.Format("{0} {1}", Eval("Contact.FirstName"), Eval("Contact.Surname"))%>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Is Active?" SortExpression="IsActive">
                            <ItemTemplate>
                                <%#(bool) Eval("IsActive")? "Yes":"No" %>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" />
                        </asp:TemplateField>
                    </Columns>
                    <PagerStyle CssClass="pagination_table"></PagerStyle>
                </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>

        <asp:ObjectDataSource ID="ObjectDataSourceServiceList" runat="server" SelectMethod="GetList"
            TypeName="AB.ServiceDirectory.BO.ServiceBO" OnSelecting="ObjectDataSourceServiceList_Selecting"
            EnablePaging="true" SelectCountMethod="GetListCount" StartRowIndexParameterName="startRowIndex"
            MaximumRowsParameterName="maxRows" SortParameterName="sortType">
            <SelectParameters>
                <asp:Parameter Name="filter" Type="Object" ConvertEmptyStringToNull="False" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
 </asp:Content>
